/**
 * 
 */
package org.insia.smartposse.xfire.service;

import java.util.ArrayList;
import java.util.List;

import org.insia.smartposse.config.DAOFactory;
import org.insia.smartposse.metier.Skill;
import org.insia.smartposse.metier.SkillCategory;
import org.insia.smartposse.metier.webservice.LightSkill;
import org.insia.smartposse.metier.webservice.LightSkillCategory;
import org.insia.smartposse.xfire.iservice.ISkillService;

/**
 * @author raguerri
 * @since 18 avr. 07
 * @version 0.0.1
 * 
 */
public class SkillService implements ISkillService {

	/* (non-Javadoc)
	 * @see org.insia.smartposse.xfire.iservice.ISkillService#get(long)
	 */
	public LightSkill get(long id) {
		LightSkill lskill = null;
		try {
			Skill skill = DAOFactory.getSkillDAO().get(id);
			lskill = skill.setLight();
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return lskill;
	}

	/* (non-Javadoc)
	 * @see org.insia.smartposse.xfire.iservice.ISkillService#getSkillCategory(long)
	 */
	public LightSkillCategory getSkillCategory(long id) {
		LightSkillCategory lskillc = null;
		try {
			SkillCategory skillc = DAOFactory.getSkillCategoryDAO().get(id);
			lskillc = skillc.setLight();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return lskillc;
	}

	/* (non-Javadoc)
	 * @see org.insia.smartposse.xfire.iservice.ISkillService#set(org.insia.smartposse.metier.webservice.LightSkill)
	 */
	public LightSkill set(LightSkill lskill) {
		// TODO Auto-generated method stub
		return null;
	}

	/* (non-Javadoc)
	 * @see org.insia.smartposse.xfire.iservice.ISkillService#setSkillCategory(org.insia.smartposse.metier.webservice.LightSkillCategory)
	 */
	public LightSkillCategory setSkillCategory(LightSkillCategory lskillcate) {
		// TODO Auto-generated method stub
		return null;
	}

	public List<LightSkillCategory> getSkillCategory() {
		List<LightSkillCategory> lskillc = new ArrayList<LightSkillCategory>();
		try {
			List<SkillCategory> skillc = DAOFactory.getSkillCategoryDAO().getList();
			for (SkillCategory category : skillc) {
				lskillc.add(category.setLight());
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return lskillc;
	}

	public List<LightSkill> getSkillWithoutCategory() {
		List<LightSkill> lskill = new ArrayList<LightSkill>();
		try {
			List<Skill> skills = DAOFactory.getSkillDAO().getSkillWithoutCategory();
			for (Skill skill : skills) {
				lskill.add(skill.setLight());
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return lskill;
	}

	/* (non-Javadoc)
	 * @see org.insia.smartposse.xfire.iservice.ISkillService#getAll()
	 */
	public List<LightSkill> getAll() {
		List<LightSkill> lskillz = new ArrayList<LightSkill>();
		try {
			List<Skill> skillz = DAOFactory.getSkillDAO().getList();
			for (Skill skill : skillz) {
				lskillz.add(skill.setLight());
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return lskillz;
	}

}
